home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / internal / i386-emul / dispatch.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  1.6 KB  |  96 lines

  1.     Exception   =    -40
  2.     Disable     =    -100
  3.     Enable        =    -105
  4.     ThisTask    =    284
  5.     IDNestCnt   =    302
  6.     TaskReady   =    428
  7.     tc_Flags    =    16
  8.     tc_State    =    17
  9.     tc_IDNestCnt=    18
  10.     tc_SPReg    =    56
  11.     tc_Switch   =    68
  12.     tc_Launch   =    72
  13.     TF_EXCEPT   =    32
  14.     TF_SWITCH   =    64
  15.     TS_RUN      =    2
  16.  
  17.     .text
  18.     .align    16
  19.     .globl    Exec_Dispatch
  20.     .type    Exec_Dispatch,@function
  21. Exec_Dispatch:
  22.     /* Push all registers */
  23.     pushl    %eax
  24.     pushl    %ebx
  25.     pushl    %ecx
  26.     pushl    %edx
  27.     pushl    %edi
  28.     pushl    %esi
  29.     pushl    %ebp
  30.  
  31.     /* Get SysBase */
  32.     movl    32(%esp),%ecx
  33.  
  34.     /* Store sp */
  35.     movl    ThisTask(%ecx),%edx
  36.     movl    %esp,tc_SPReg(%edx)
  37.  
  38.     /* Switch bit set? */
  39.     testb    $TF_SWITCH,tc_Flags(%edx)
  40.     je    noswch
  41.     movl    tc_Switch(%edx),%eax
  42.     call    *%eax
  43.  
  44.     /* Store IDNestCnt */
  45. noswch:    movb    IDNestCnt(%ecx),%al
  46.     movb    %al,tc_IDNestCnt(%edx)
  47.     movb    $-1,IDNestCnt(%ecx)
  48.  
  49.     /* Get task from ready list */
  50.     movl    TaskReady(%ecx),%edx
  51.     movl    (%edx),%eax
  52.     movl    %eax,TaskReady(%ecx)
  53.     movl    (%edx),%eax
  54.     leal    TaskReady(%ecx),%ebx
  55.     movl    %ebx,4(%eax)
  56.     movl    %edx,ThisTask(%ecx)
  57.  
  58.     /* Use as current task */
  59.     movb    $TS_RUN,tc_State(%edx)
  60.     movb    tc_IDNestCnt(%edx),%al
  61.     movb    %al,IDNestCnt(%ecx)
  62.  
  63.     /* Launch bit set? */
  64.     cmpb    $0,tc_Flags(%edx)
  65.     jge    nolnch
  66.     movl    tc_Launch(%edx),%eax
  67.     call    *%eax
  68.  
  69.     /* Get new sp */
  70. nolnch:    movl    tc_SPReg(%edx),%esp
  71.  
  72.     /* Except bit set? */
  73.     testb    $TF_EXCEPT,tc_Flags(%edx)
  74.     je    noexpt
  75.  
  76.     /* Raise task exception in Disable()d state */
  77.     pushl    %ecx
  78.     leal    Disable(%ecx),%eax
  79.     call    *%eax
  80.     leal    Exception(%ecx),%eax
  81.     call    *%eax
  82.     movl    (%esp),%ecx
  83.     leal    Enable(%ecx),%eax
  84.     call    *%eax
  85.     addl    $4,%esp
  86.  
  87.     /* Restore registers and return */
  88. noexpt:    popl    %ebp
  89.     popl    %esi
  90.     popl    %edi
  91.     popl    %edx
  92.     popl    %ecx
  93.     popl    %ebx
  94.     popl    %eax
  95.     ret
  96.